﻿@model XPressify.Models.AlbumViewerListModel
@using Omu.Awesome.Core;
@using Omu.Awesome.Mvc.Helpers;
@using XPressify.Controllers;
@using XPressify.Data.Helpers

@if(Model.IsAjaxRequest)
{
    {
        ViewBag.Title = "Albums";
    }
}
else
{
    {
        ViewBag.Title = "Albums";
        Layout = "~/Views/Shared/_Layout.cshtml";
    }
}

<script type="text/javascript">

    $(document).ready(function () {
        $('#ui-tabs-4').css('font', '13px "Trebuchet MS", Verdana, Helvetica, sans-serif');
        $('.nobtn').css('color', 'blue');

    });

</script>


<h2 style="color:#222">Albums</h2>
<div>
By:
    @if (Model.SubjectType == SubjectType.User)
    {
        @Html.ActionLink(Model.SubjectName, "ProfileView", "Profile", new { id = Model.SubjectId }, new { @class = "nobtn" })
    }
    else if (Model.SubjectType == SubjectType.Event)
    {
        @Html.ActionLink(Model.SubjectName, "EventDetails", "Event", new { id = Model.SubjectId }, new { @class = "nobtn" })
    }
    else if (Model.SubjectType == SubjectType.Group)
    {
        @Html.ActionLink(Model.SubjectName, "GroupDetails", "Group", new { id = Model.SubjectId }, new { @class = "nobtn" })
    }
    else if (Model.SubjectType == SubjectType.Page)
    {
        @Html.ActionLink(Model.SubjectName, "PageDetails", "Page", new { id = Model.SubjectId }, new { @class = "nobtn" })
    }
</div>

<div align="left">
<table style="width:0%;" >

@{var i = 0;
  var j = 0;

  for (i = 0; i < Model.Albums.Count(); i++)
  {
        <tr>
            
            @for (j = i; j < Model.Albums.Count(); j++)
            {
                <td width="150px" align="center">
                    @if (Model.Albums.ElementAt(j).IsOwner == true)
                    {
                    <table border="0" cellpadding="0" cellspacing="0" style="margin:0px;padding:0px;height:42px">
                    <tr>
                    @if (Model.Albums.ElementAt(j).IsDeletable == true)
                    {
                        <td style="text-align:center">
                        @(Html.MakePopupForm<AlbumController>(o => o.AlbumInfoEdit(Model.Albums.ElementAt(j).Id), title: "Edit", height: 550, width: 600, okText: "Save", resizable: false, refreshOnSuccess: true))
                        @(Html.PopupFormActionLink<AlbumController>(o => o.AlbumInfoEdit(Model.Albums.ElementAt(j).Id), "Edit", new { @class = "nobtn" }))
                        </td>
                        <td style="text-align:center">
                        @Html.Confirm("Are you sure you want to delete this album?", "myconfirmBtn", title: "Delete album", yesText: "Delete") 
                        
                        @using (Html.BeginForm("AlbumDelete", "Album", FormMethod.Get, new { style = "width:20px;font-weight:normal" }))
                        {
                                @Html.HiddenFor(model => Model.Albums.ElementAt(j).Id)
                                <input type="submit" value="Delete" class="myconfirmBtn" id="nounderline" style="font-weight:normal" onmouseover="changeIdToObject(this)" onmouseout="changeIdToObject(this)"/>
                        }
                        </td>
                    }
                    else if (Model.Albums.ElementAt(j).IsDeletable == false)
                    {
                        <td style="text-align:center">
                        @(Html.MakePopupForm<AlbumController>(o => o.AlbumPrivacyEdit(Model.Albums.ElementAt(j).Id), title: "Edit", height: 365, width: 500, okText: "Save", resizable: false, refreshOnSuccess: true))
                        @(Html.PopupFormActionLink<AlbumController>(o => o.AlbumPrivacyEdit(Model.Albums.ElementAt(j).Id), "Edit", new { @class = "nobtn" }))
                        </td>
                    }
                    </tr>
                    </table>
                    }
                    <a href='@Url.Action("AlbumDetails", "Album", new { id = Model.Albums.ElementAt(j).Id })' class="nobtn">
                            <img src="@Model.Albums.ElementAt(j).CoverPicturePath" alt="@Model.Albums.ElementAt(j).Name" title="@Model.Albums.ElementAt(j).Name"  style="width:150px;height:150px"/>
                    </a>
                    <br />
                    @Html.ActionLink(Model.Albums.ElementAt(j).Name, "AlbumDetails", "Album", new { id = Model.Albums.ElementAt(j).Id }, new { @class = "nobtn" })
                    <br />
                    @Model.Albums.ElementAt(j).MediaCount files
                </td>
               if ((j + 1) % 4 == 0)
               {
                   break;
               }
            }
            @{i = j;}
        </tr>
        
  }
        
    }

</table>
</div>